function render(arguments, option) {
    var domid = /function\s+render_(\w+)/.exec(arguments.callee)[1]
    echarts.init(document.getElementById(domid)).setOption(option)
}
// 2.3.3.   日期-提交数-贡献者
function render_commits_contributors(data) {
    var x_data = [],
        y1_data = [],
        y2_data = []
    for (i in data.commits) {
        x_data.push(data.commits[i][0])
        y1_data.push(data.commits[i][1])
    }
    for (i in data.contributors) {
        y2_data.push(data.contributors[i][1])
    }
    var option = {
        color: ['#396bff', '#ff6030'],
        tooltip: {
            trigger: 'axis',
            axisPointer: { type: 'cross' },
            formatter: function(params, ticket, callback) {
                var res = params[0].name
                for (var i = 0, l = params.length; i < l; i++) {
                    if (params[i].seriesType === 'line') {
                        res += '<br/>' + params[i].seriesName + ' : ' + (params[i].value ? params[i].value : '-')
                    } else {
                        res += '<br/>' + params[i].seriesName + ' : ' + (params[i].value ? params[i].value : '-')
                    }
                }
                return res
            }
        },
        grid: {
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            axisTick: {
                alignWithLabel: true
            },
            data: x_data
        }],
        yAxis: [{
            name: '提交数(次)',
            type: 'value',
            position: 'left'
        }, {
            name: '贡献者(个)',
            type: 'value',
            position: 'right'
        }],
        series: [{
            name: '提交数',
            type: 'bar',
            yAxisIndex: 1,
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: y1_data
        }, {
            name: '贡献者',
            type: 'line',
            label: {
                normal: {
                    show: true,
                    position: 'top',
                }
            },
            lineStyle: {
                normal: {
                    width: 3,
                    shadowColor: 'rgba(0,0,0,0.4)',
                    shadowBlur: 10,
                    shadowOffsetY: 10
                }
            },
            data: y2_data
        }]
    }
    render(arguments, option)
}
// 2.3.4.   贡献者等级
function render_contributors_level(data) {
    var p_data = []
    for (k in data) {
        if (data[k] > 0) {
            p_data.push({ name: 'Level ' + k, value: data[k] })
        }
    }
    var option = {
        tooltip: {
            trigger: 'item',
            formatter: function(params) {
                return params.name + ' ' + params.value + '人'
            }
        },
        grid: {
            containLabel: true
        },
        series: [{
            name: '贡献者',
            type: 'pie',
            radius: '50%',
            data: p_data
        }]
    }
    render(arguments, option)
}
// 2.4.2.   项目关注情况
function render_activity_git_stat(data) {
    var option = {
        tooltip: {
            trigger: 'item',
            formatter: function(params) {
                return params.name + ' ' + params.value + '人'
            }
        },
        grid: {
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            axisTick: {
                alignWithLabel: true
            },
            data: ['watch', 'star', 'fork']
        }],
        yAxis: {
            name: '数量(人)',
            type: 'value'
        },
        series: [{
            type: 'bar',
            itemStyle: {
                normal: {
                    color: function(params) {
                        return ['#4f81bd', '#c0504d', '#9bbb59'][params.dataIndex]
                    },
                    label: { show: true, position: 'top' }
                }
            },
            data: [data.watch, data.star, data.fork]
        }]
    }
    render(arguments, option)
}
// 2.4.3.   项目需求情况
function render_activity_git_pull(data) {
    var option = {
        tooltip: {
            trigger: 'item',
            formatter: function(params) {
                return params.name + ' ' + params.value
            }
        },
        grid: {
            left: 0,
            right: 0,
            containLabel: true
        },
        series: [{
            name: 'Request',
            type: 'pie',
            radius: '50%',
            color: ['#4e81bd', '#c1504c'],
            data: [{ name: 'Open', value: data.open }, { name: 'Close', value: data.close }]
        }]
    }
    render(arguments, option)
}
// 2.4.4.   项目讨论情况
function render_activity_git_issues(data) {
    var option = {
        tooltip: {
            trigger: 'item',
            formatter: function(params) {
                return params.name + ' ' + params.value
            }
        },
        grid: {
            left: 0,
            right: 0,
            containLabel: true
        },
        series: [{
            name: 'Issues',
            type: 'pie',
            radius: '50%',
            color: ['#4e81bd', '#c1504c'],
            data: [{ name: 'Open', value: data.open }, { name: 'Close', value: data.close }]
        }]
    }
    render(arguments, option)
}
// 2.4.5-2.4.8
function activity_option(data) {
    var x_data = [],
        y_data = []
    for (k in data) {
        x_data.push(k)
        y_data.push(data[k])
    }
    var option = {
        tooltip: {
            trigger: 'item',
            formatter: function(params) {
                return params.name + ' ' + params.value + '条'
            }
        },
        grid: {
            left: 10,
            right: 10,
            buttom: 0,
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            data: x_data
        }],
        yAxis: {
            type: 'value'
        },
        series: [{
            type: 'bar',
            itemStyle: {
                normal: {
                    color: function(params) {
                        return ['#4f81bd', '#86D560', '#AF89D6', '#59ADF3', '#FF999A', '#FFCC67'][params.dataIndex]
                    },
                    label: { show: true, position: 'top' }
                }
            },
            data: y_data
        }]
    }
    return option
}
// 2.4.5.   博客类
function render_activity_blogs(data) {
    var option = activity_option(data)
    render(arguments, option)
}
// 2.4.6.   论坛类
function render_activity_bbs(data) {
    var option = activity_option(data)
    render(arguments, option)
}
// 2.4.7.   书籍类
function render_activity_books(data) {
    var option = activity_option(data)
    render(arguments, option)
}
// 2.4.8.   搜索类
function render_activity_searchs(data) {
    var option = activity_option(data)
    render(arguments, option)
}
// 2.5.1.   最新版代码信息
function render_code_info(data) {
    var option = {
        tooltip: {
            trigger: 'item',
            formatter: function(params) {
                return params.name + ' ' + params.value
            }
        },
        grid: {
            containLabel: true
        },
        series: [{
            name: '代码',
            type: 'pie',
            radius: '80%',
            color: ['#4f81bd', '#86D560', '#AF89D6'],
            data: [{ name: 'Codes', value: data.codes }, { name: 'Comments', value: data.comments }, { name: 'Blanks', value: data.blanks }]
        }]
    }
    render(arguments, option)
}
// 2.5.2.   最新版语言占比
function render_code_languages(data) {
    var p_data = []
    for(k in data) {
        p_data.push({ name: k, value: data[k].replace('%', '') })
    }
    var option = {
        color: ['#4f81bd', '#86D560', '#AF89D6', '#59ADF3', '#FF999A', '#FFCC67'],
        tooltip: {
            trigger: 'item',
            formatter: function(params) {
                return params.name + ' ' + params.value + '%'
            }
        },
        grid: {
            containLabel: true
        },
        series: [{
            name: '语言',
            type: 'pie',
            radius: '60%',
            data: p_data
        }]
    }
    render(arguments, option)
}
// 2.5.3.   日期-代码/注释/空行
function render_code_by_date(data) {
    var x_data = [], y1_data = [], y2_data = [], y3_data = []
    for (i in data.codes) {
        x_data.push(data.codes[i][0])
        y1_data.push(data.codes[i][1])
    }
    for (i in data.comments) {
        y2_data.push(data.comments[i][1])
    }
    for (i in data.blanks) {
        y3_data.push(data.blanks[i][1])
    }
    var option = {
        color: ['#4f81bd', '#86D560', '#AF89D6'],
        tooltip: {
            trigger: 'axis'
        },
        grid: {
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            axisTick: {
                alignWithLabel: true
            },
            data: x_data
        }],
        yAxis: [{
            name: '行数',
            type: 'value',
            min: 1,
            position: 'right'
        }],
        series: [{
            name: '代码行',
            type: 'line',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: y1_data
        }, {
            name: '注释行',
            type: 'line',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: y2_data
        }, {
            name: '空行',
            type: 'line',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: y3_data
        }]
    }
    render(arguments, option)
}
// 2.5.4.   版本-代码行数
function render_code_by_tag(data) {
    var x1_data = [], x2_data = [], y1_data = [], y2_data = [], y3_data = []
    for (i in data) {
        x1_data.push(data[i].ver)
        x2_data.push(data[i].d)
        y1_data.push(data[i].codes)
        y2_data.push(data[i].comments)
        y3_data.push(data[i].blanks)
    }
    var option = {
        color: ['#4f81bd', '#86D560', '#AF89D6'],
        tooltip: {
            trigger: 'axis'
        },
        grid: {
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            axisTick: {
                alignWithLabel: true
            },
            position: 'bottom',
            data: x1_data
        }, {
            type: 'category',
            axisTick: {
                alignWithLabel: true
            },
            position: 'bottom',
            offset: 20,
            data: x2_data
        }],
        yAxis: [{
            name: '行数',
            type: 'value',
            min: 1,
            position: 'right'
        }],
        series: [{
            name: '代码行',
            type: 'line',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: y1_data
        }, {
            name: '注释行',
            type: 'line',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: y2_data
        }, {
            name: '空行',
            type: 'line',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: y3_data
        }]
    }
    render(arguments, option)
}
// 2.6.1.   漏洞信息
function render_security_info(data) {
    var x_data = [], y_data = [], o = {}
    for (k in data) {
        if (o[data[k].ptime]) {
            o[data[k].ptime] += 1
        } else {
            o[data[k].ptime] = 1
        }
    }
    for (k in o) {
        x_data.push(k)
        y_data.push(o[k])
    }
    var option = {
        color: ['#ffc000'],
        tooltip: {
            trigger: 'axis'
        },
        grid: {
            // left: 10,
            // right: 10,
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            axisTick: {
                alignWithLabel: true
            },
            min: 0,
            data: x_data
        }],
        yAxis: [{
            name: '行数',
            type: 'value',
            min: 1,
            position: 'right'
        }],
        series: [{
            name: '代码行',
            type: 'line',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data: y_data
        }]
    }
    render(arguments, option)
}
function render_security_level(data) {
    var level_h = 0, level_m = 0, level_l = 0, level_o = 0
    for (k in data) {
        switch (data[k].level) {
            case '高危': level_h += 1; break;
            case '中危': level_m += 1; break;
            case '低危': level_l += 1; break;
            default: level_o += 1;
        }
    }
    var option = {
        color: ['#FFCC67', '#FF999A', '#59ADF3'],
        tooltip: {
            trigger: 'item',
            formatter: function(params) {
                return params.name + ' ' + params.value + '个'
            }
        },
        grid: {
            containLabel: true
        },
        series: [{
            name: '贡献者',
            type: 'pie',
            radius: '50%',
            data: [{ name: '高危', value: level_h }, { name: '中危', value: level_m }, { name: '低危', value: level_l }]
        }]
    }
    render(arguments, option)
}
function render_security_list(data) {
    for (k in data) {
        var html = ""
        html+='<li class="loophole_color">';
        html+='    <ul class="detail">';
        html+='        <li><a href="'+data[k].en_url+'">'+data[k].cve+'</a><br><br><a href="'+data[k].zh_url+'">'+data[k].cnnvd+'</a></li>';
        html+='        <li class="'+(data[k].level=='高危'?'level_h':(data[k].level=='中危'?'level_m':'level_l'))+'">'+data[k].level+'</li>';
        html+='        <li>'+data[k].ptime+'</li>';
        html+='        <li><a href="'+data[k].en_url+'" target="_blank">'+data[k].description.substr(0, 70) +'...</a></li>';
        html+='    </ul>';
        html+='</li>';
        $('#security_list').append(html)
    }
}